package com.xuelang.pipeline.entry.application;

import com.xuelang.pipeline.app.application.TraitService;
import com.xuelang.pipeline.client.application.ITraitService;
import com.xuelang.pipeline.client.application.dto.TraitDTO;
import com.xuelang.pipeline.client.application.dto.TraitQuery;
import com.xuelang.pipeline.client.common.request.PageParam;
import com.xuelang.pipeline.client.common.result.ApiResult;
import com.xuelang.pipeline.client.common.result.PageRecord;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 运维特征服务web控制类
 *
 * @author xiwen.zxg
 * @since 2024/5/15
 */
@Slf4j
@RestController
@RequestMapping("/trait")
public class TraitController implements ITraitService {

    @Autowired
    @Qualifier("traitServiceImpl")
    private TraitService traintService;

    @Override
    public ApiResult<PageRecord<TraitDTO>> pageTraitList(PageParam<TraitQuery> dtoPageParam) {
        return ApiResult.success(traintService.pageList(dtoPageParam));
    }

    @Override
    public ApiResult<List<TraitDTO>> conditionalTraitList(TraitQuery trainQuery) {
        return ApiResult.success(traintService.list(trainQuery));
    }

    @Override
    public ApiResult<Boolean> addTrait(TraitDTO traintDTO) {
        return ApiResult.success(traintService.add(traintDTO));
    }

    @Override
    public ApiResult<Boolean> updateTrait(TraitDTO traintDTO) {
        return ApiResult.success(traintService.update(traintDTO));
    }

    @Override
    public ApiResult<Boolean> deleteTrait(String traintUuid) {
        return ApiResult.success(traintService.delete(traintUuid));
    }

    @Override
    public ApiResult<TraitDTO> queryTrait(String traintUuid) {
        return ApiResult.success(traintService.query(traintUuid));
    }
}